package com.olinsports.system.olinsportssystem.controller;

import com.olinsports.system.olinsportssystem.manager.CommodityDetailedManager;
import com.olinsports.system.olinsportssystem.manager.CommodityTypeManager;
import com.olinsports.system.olinsportssystem.model.CommodityDetailed;
import com.olinsports.system.olinsportssystem.model.CommodityType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/7/22.
 */
@Controller
@RequestMapping("commodityDetailed")
public class CommodityDeatiledController {
    @Autowired
    private CommodityDetailedManager commodityDetailedManager;

    @RequestMapping("/selectAll")
    @ResponseBody
    public List<CommodityDetailed> selectAll(){
        return commodityDetailedManager.selectAll();
    }

    @RequestMapping("/insertAll")
    @ResponseBody
    public int insertAll(CommodityDetailed commodityDetailed){
        return commodityDetailedManager.insertAll(commodityDetailed);
    }

    @RequestMapping("/deleteByKey")
    @ResponseBody
    public int deleteByKey(int detailedKey){
        return commodityDetailedManager.deleteByKey(detailedKey);
    }

    @RequestMapping("/updateData")
    @ResponseBody
    public int updateData(CommodityDetailed commodityDetailed){
        return commodityDetailedManager.updateData(commodityDetailed);
    }

    @RequestMapping("/selectByKey")
    @ResponseBody
    public CommodityDetailed selectByKey(int detailedKey){
        return commodityDetailedManager.selectByKey(detailedKey);
    }

    @RequestMapping("/saveOrUpdateCommDetal")
    @ResponseBody
    public int saveOrUpdateCommDetal(CommodityDetailed commodityDetailed,int typeKey){
        System.out.println("commodityDetailed = "+commodityDetailed);
        return commodityDetailedManager.saveOrUpdateCommDetal(commodityDetailed,typeKey);
    }

    @RequestMapping("/listDetailed")
    @ResponseBody
    public Map listDetailed(String page, String rows, boolean _search, String sord, String sidx){
        return commodityDetailedManager.listDetailed(page,rows,_search,sord,sidx);
    }

    @RequestMapping("/searchSelf")
    @ResponseBody
    public Map searchSelf(String page, String rows,String field,String fieldValue){
        return commodityDetailedManager.searchSelf(page,rows,field,fieldValue);
    }

    @RequestMapping("/selectBySkuType")
    @ResponseBody
    public List<CommodityDetailed> selectBySkuType(int skuType){
        return commodityDetailedManager.selectBySkuType(skuType);
    }
}
